﻿using Joz.RabbitMQClient.Enum;
using System;

namespace Joz.RabbitMQClient
{
    /// <summary>
    /// RabbitMq client 接口。
    /// </summary>
    public interface IRabbitMqClient : IDisposable
    {
        /// <summary>
        /// RabbitMqClient 数据上下文。
        /// </summary>
        RabbitMqClientContext Context { get; set; }

        /// <summary>
        /// 消息被本地激活事件。通过绑定该事件来获取消息队列推送过来的消息。只能绑定一个事件处理程序。
        /// </summary>
        event ActionEvent ActionEventMessage;

        /// <summary>
        /// 交换机名称为FanoutExchange，模式为Fanout的一个实体推送消息
        /// </summary>
        /// <param name="eventMessage">发送的消息实例</param>
        /// <param name="queue">队列名称</param>
        /// <param name="DeliveryMode">是否持久化数据</param>
        void TriggerFanoutEventMessage(EventMessage eventMessage, string queue, bool DeliveryMode = true);

        /// <summary>
        /// 交换机名称为DirecExchange，模式为Direc的一个实体推送消息
        /// </summary>
        /// <param name="eventMessage">发送的消息实例</param>
        /// <param name="queue">队列名称</param>
        /// <param name="DeliveryMode">是否持久化数据</param>
        void TriggerDirectEventMessage(EventMessage eventMessage, string queue, bool DeliveryMode = true);

        /// <summary>
        /// 交换机名称为TopicExchange，模式为Topic的一个实体推送消息
        /// </summary>
        /// <param name="eventMessage">发送的消息实例</param>
        /// <param name="queue">队列名称</param>
        /// <param name="DeliveryMode">是否持久化数据</param>
        void TriggerTopicEventMessage(EventMessage eventMessage, string queue, bool DeliveryMode = true);

        /// <summary>
        /// 可配置性较高的一个通用消息推送
        /// </summary>
        /// <param name="eventMessage">发送的消息实例</param>
        /// <param name="exChange">RabbitMq的Exchange名称</param>
        /// <param name="queue">队列名称</param>
        /// <param name="extype">交换机模式</param>
        /// <param name="DeliveryMode">是否持久化消息</param>
        void TriggerEventMessage(EventMessage eventMessage, string exChange, string queue, ExchangeTypeEnum extype, bool DeliveryMode = true);


        /// <summary>
        /// 开始消息队列的默认监听。
        /// </summary>
        void OnListening();
    }
}